@extends('Admin.common.header')

<!-- 1.添加meta csrf_token -->
<meta name="csrf-token" content="{{ csrf_token() }}">  
<script src=" {{ asset('./js/jquery-1.8.3.min.js') }} "></script>
<script>
	<!-- 2.设置全局ajax选项 -->
	$.ajaxSetup({
		headers: {
			'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
		}
	});
	var _token = $('meta[name="csrf-token"]').attr('content');
	
	
	// 删除 留言
	function delMsg( msgId )
	{
		
		$.ajax({
			type:"post",
			url:"{{ url('/delMsg') }}"+'/'+msgId,
			data:{ _token:_token },
			async:true,    					
			dataType:"text",
			success:function(back){
				if(back=='1')
				{
					location.reload();
				}
			}
		});
		
	}
	
	// 已读 收藏 操作
	function upType( msgId,type )
	{
		
		$.ajax({
			type:"post",
			url:"{{ url('/upMsgType') }}"+'/'+msgId,
			data:{ type,type,_token:_token },
			async:true,    					
			dataType:"text",
			success:function(back){
				if(back=='1')
				{
					location.reload();
				}
			}
		});
		
	}
	
</script>


<br/><br/><br/><br/>


<!-- 页面标记 -->
<div style="margin-left:250px;">
	<mark style="font-size:18px;">未读留言列表</mark>
</div>


<br/>


<div class="list-group" style="width:60%;margin:0 auto;">
@forelse($all_message as $key=>$message_info)
		@if( $key%4 == 0 )
			<div class="list-group-item list-group-item-success" style="float:left;height:auto;">
				
				<div style="float:left;width:100px;">
					{{ $message_info->create_at }}
				</div>
				<div style="float:left;width:480px;word-wrap:break-word;">
					{{ $message_info->message }}
				</div>
				
				<div style="float:left;width:115px;margin-left:20px;">
					
					<!-- 删除  -->
					<a onclick="delMsg( {{ $message_info->id }} );" style="float:left;margin-right:20px;font-size:16px;cursor:pointer;" >
						<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
					</a>
					<!-- 收藏 -->
					<a onclick="upType( {{ $message_info->id }},3 );" style="float:left;margin-right:20px;font-size:18px;margin-top:-2px;cursor:pointer;" >
						<span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span>
						<!--<span class="glyphicon glyphicon-star" aria-hidden="true"></span>-->
					</a>
					<!-- 已读  -->
					<a onclick="upType( {{ $message_info->id }},2 );"  style="float:left;margin-right:20px;font-size:16px;cursor:pointer;" >
						<span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span>
					</a>
				</div>
				
			</div>
		@elseif( $key%3 == 0 )
			<div class="list-group-item list-group-item-info" style="float:left;height:auto;">
				
				<div style="float:left;width:100px;">
					{{ $message_info->create_at }}
				</div>
				<div style="float:left;width:480px;word-wrap:break-word;">
					{{ $message_info->message }}
				</div>
				
				<div style="float:left;width:115px;margin-left:20px;">
					
					<!-- 删除  -->
					<a onclick="delMsg( {{ $message_info->id }} );" style="float:left;margin-right:20px;font-size:16px;cursor:pointer;" >
						<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
					</a>
					<!-- 收藏 -->
					<a onclick="upType( {{ $message_info->id }},3 );" style="float:left;margin-right:20px;font-size:18px;margin-top:-2px;cursor:pointer;" >
						<span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span>
						<!--<span class="glyphicon glyphicon-star" aria-hidden="true"></span>-->
					</a>
					<!-- 已读  -->
					<a onclick="upType( {{ $message_info->id }},2 );"  style="float:left;margin-right:20px;font-size:16px;cursor:pointer;" >
						<span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span>
					</a>
				</div>
				
			</div>
			
		@elseif( $key%2 == 0 )
			<div class="list-group-item list-group-item-warning" style="float:left;height:auto;">
				
				<div style="float:left;width:100px;">
					{{ $message_info->create_at }}
				</div>
				<div style="float:left;width:480px;word-wrap:break-word;">
					{{ $message_info->message }}
				</div>
				
				<div style="float:left;width:115px;margin-left:20px;">
					
					<!-- 删除  -->
					<a onclick="delMsg( {{ $message_info->id }} );" style="float:left;margin-right:20px;font-size:16px;cursor:pointer;" >
						<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
					</a>
					<!-- 收藏 -->
					<a onclick="upType( {{ $message_info->id }},3 );" style="float:left;margin-right:20px;font-size:18px;margin-top:-2px;cursor:pointer;" >
						<span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span>
						<!--<span class="glyphicon glyphicon-star" aria-hidden="true"></span>-->
					</a>
					<!-- 已读  -->
					<a onclick="upType( {{ $message_info->id }},2 );"  style="float:left;margin-right:20px;font-size:16px;cursor:pointer;" >
						<span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span>
					</a>
				</div>
				
			</div>
			
		@else
			<div class="list-group-item list-group-item-danger" style="float:left;height:auto;">
				<div style="float:left;width:100px;">
					{{ $message_info->create_at }}
				</div>
				<div style="float:left;width:480px;word-wrap:break-word;">
					{{ $message_info->message }}
				</div>
				
				<div style="float:left;width:115px;margin-left:20px;">
					
					<!-- 删除  -->
					<a onclick="delMsg( {{ $message_info->id }} );" style="float:left;margin-right:20px;font-size:16px;cursor:pointer;" >
						<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
					</a>
					<!-- 收藏 -->
					<a onclick="upType( {{ $message_info->id }},3 );" style="float:left;margin-right:20px;font-size:18px;margin-top:-2px;cursor:pointer;" >
						<span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span>
						<!--<span class="glyphicon glyphicon-star" aria-hidden="true"></span>-->
					</a>
					<!-- 已读  -->
					<a onclick="upType( {{ $message_info->id }},2 );"  style="float:left;margin-right:20px;font-size:16px;cursor:pointer;" >
						<span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span>
					</a>
				</div>
				
			</div>
			
		@endif
@empty
	<h2>暂无新增留言</h2>
@endforelse
</div>



@extends('Admin.common.footer')